<?php
//namespace app\model\front;
namespace app\model;
include EXTEND_PATH."alidayu_sms/TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

//use think\Db;

class Ali_sms
{
    function __construct() {
        $this->appkey    = '';
        $this->secretKey = '';
    }

    /*
     * $phone：手机号
     * $signname:短信签名
     * $tplcode :短信模板
     * $setsmsparam：验证码(eg:{code:'1111'})
     */
    public function send($phone,$signname,$tplcode,$setsmsparam)
    {
        $c = new \TopClient;
        $c ->appkey = $this->appkey;
        $c ->secretKey = $this->secretKey;
        $req = new \AlibabaAliqinFcSmsNumSendRequest;
        $req ->setExtend( "" );
        $req ->setSmsType( "normal" );
        $req ->setSmsFreeSignName($signname);
        $req ->setSmsParam($setsmsparam);
        $req ->setRecNum($phone);
        $req ->setSmsTemplateCode($tplcode);
        $resp = $c ->execute( $req );
        $sms_status = $resp->code;
        if($sms_status>0){
            return false;
        }else{
            return true;
        }
    }

}


